package com.itheima.server.controller;

import com.itheima.server.service.PeachBlossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 阿鹏
 * @date 2021/2/25 1:20
 */
@RestController
@RequestMapping("/peachblossom")
public class PeachBlossomController {

    @Autowired
    private PeachBlossomService peachBlossomService;

    /**
     * 发送语音
     * @param soundFile
     * @return
     * @throws IOException
     */
    @PostMapping
    public ResponseEntity saveSound(@RequestParam(required = false) MultipartFile soundFile) throws IOException {
        return peachBlossomService.sendSoundFile(soundFile);
    }

    /**
     * 接收语音
     * @return
     * @throws Exception
     */
    @GetMapping
    public ResponseEntity getSound() throws Exception {
        return peachBlossomService.receiveSoundFile();
    }
}
